package com.spoto.oa.service.impl;


import com.spoto.oa.dao.EmployeeDAO;
import com.spoto.oa.dao.impl.EmployeeDAOImpl;
import com.spoto.oa.model.Employee;
import com.spoto.oa.service.LoginServ;
/**
 * 
 * @Project_name: OA
 * @Description: 登陆界面功能的具体实现
 * @Author: LinYiSong
 * @Version: 
 * @Date: 2010-9-23~2010-9-23
 */
public class LoginServImpl implements LoginServ {

	/**
	 * 分析登陆界面上提供的员工信息
	 * -2 不存在该用户
	 * -1 存在但密码不正确
	 * 0 员工
	 * 1 系统管理员
	 */
	public String analysesEmployee(Employee employee) {
		
		String username=employee.getUsername();
		String password=employee.getPassword();
		EmployeeDAO employeeDAO=new EmployeeDAOImpl();
		Employee temp=null;
	    temp=employeeDAO.getByUsername(username);
	    if(null==temp){
	    	return "-2";
	    }else if(!password.equals(temp.getPassword())){
	    	return "-1";
	    }else{
	    	if(temp.getIsAdmin().equals("是")){
	    		return "1";
	    	}else{
	    		return "0";
	    	}
	    }
	}
	

}
